package com.yunzheng.studyLeaveSystem.modules.user.user_info.servlet; /**
 * Created with IntelliJ IDEA.
 *
 * @Author: YunZheng
 * @Date: 2023/01/31/16:45
 * @Description:
 */

import com.yunzheng.studyLeaveSystem.modules.user.user_info.service.User_infoService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "UpdatePasswordServlet", value = "/UpdatePasswordServlet")
public class UpdatePasswordServlet extends HttpServlet {
    private User_infoService user_infoService = new User_infoService();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        HttpSession session = request.getSession();
        String phone_num = (String) session.getAttribute("phone_num");
        String password = request.getParameter("password");
        String password2 = request.getParameter("password2");
        String password3 = request.getParameter("password3");
        String massage = null;
        try {
             massage = user_infoService.updatePassword(password, password2, password3, phone_num);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        request.setAttribute("massage", massage);
        //返回个人信息账号安全页面
        request.getRequestDispatcher("/").forward(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
